package com.atguigu.eduService.controller;


import com.atguigu.commonUtils.Result;
import com.atguigu.commonUtils.ResultUtil;
import com.atguigu.eduService.entity.EduSubject;
import com.atguigu.eduService.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Chen Wen bo
 * @since 2021-07-22
 */
@Api(tags = "课程分类管理")
@RestController
    @RequestMapping("/eduService/subject")
@CrossOrigin
public class EduSubjectController {

    @Resource
    private EduSubjectService eduSubjectService;

    @ApiOperation("添加课程分类")
    @PostMapping("/addSubject")
    public Result<EduSubject> addSubject(MultipartFile file){
        eduSubjectService.addSubject(file, eduSubjectService);
        return ResultUtil.success();
    }


    @ApiOperation("课程列表")
    @GetMapping("/getSubject")
    public Result<List<EduSubject>> getSubject(){
        return ResultUtil.success(eduSubjectService.getSubject());
    }

}

